package cn.itcast.utils;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateUtils 
{
		static Configuration configuration =null;
		static SessionFactory sessionFactory = null;
		static
		{
			// 加载一次配置文件
			configuration = new Configuration();
			configuration.configure();
			
			// 获取一个sessionFactory
			sessionFactory=configuration.buildSessionFactory();
			
		}
		
		public static Session openSession()
		{
			return sessionFactory.openSession();
		}
}
